<!doctype html>
<html xmlns:th="http://www.thymeleaf.org"  lang="zh-CN">
<head>
  <title>清华大学学生教育互联网公益协会</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
  <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" />
  <script th:src = "@{/js/jquery.min.js}"></script>
  <script th:src = "@{/js/bootstrap.min.js}"></script>

  <style>
    .navbar-brand {
      padding: 0 15px;
    }
  </style>
</head>
<body>
  <div class="container">
    <header>
      <nav class="navbar navbar-default bg-faded">
        <div class="container-fluid">
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#"><img th:src="@{/img/brand.jpg}" height="50"/></a>
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
              <li class="nav-item active"><a href="#">i玩问答</a></li>
              <li class="nav-item"><a th:href="profile">个人信息</a></li>
              <li class="nav-item"><a th:href="@{/volunteers}">哥哥姐姐</a></li>
              <li class="nav-item"><a th:href="@{/look}">i玩课堂</a></li>
              <li class="nav-item"><a th:href="@{/logout}">退出登录</a></li>
            </ul>
          </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
      </nav>
    </header>
    <main>
      <a class = "btn btn-primary" th:href="@{/question}">
        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 新建
      </a>
      <form class="navbar-form" role="search" style="display:inline-block">
        <div class="input-group">
            <input name="keyword" type="text" class="form-control" placeholder="按标题搜索" id="search" />
            <input name="status" type="hidden" th:value="${status}" />
            <input name="page" type="hidden" th:value="${questions.number}" />
            <div class="input-group-btn">
                <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
            </div>
        </div>
      </form>
      <ul class="nav nav-tabs">
        <li role="presentation" th:class="${status.equals('WAITING')? 'active':''}">
        	<a th:href="${status.equals('WAITING')? '#' : '?status=WAITING' + '&amp;page=' + questions.number }">未回答</a>
        </li>
        <li role="presentation" th:class="${status.equals('ANSWERED')? 'active':''}">
        	<a th:href="${status.equals('ANSWERED')? '#' : '?status=ANSWERED' + '&amp;page=' + questions.number }">回答中</a>
        </li>
        <li role="presentation" th:class="${status.equals('CLOSED')? 'active':''}">
        	<a th:href="${status.equals('CLOSED')? '#' : '?status=CLOSED' + '&amp;page=' + questions.number }">已懂</a>
        </li>
      </ul>
      <div class="row clearfix">
        <div th:each="question : ${questions}" class="col-sm-4 clearfix">
          <h2 th:text="${question.title}"></h2>
          <p th:text="${question.description}"></p>
          <p>
            <a class="btn btn-primary pull-left" th:href="@{'/question/' + ${question.id} }">
              查看详情 <span class="glyphicon glyphicon-circle-arrow-right"></span>
            </a>
          </p>
        </div>
      </div>
      <nav th:if="${questions.totalPages > 1}" aria-label="Page navigation">
		 <ul class="pagination">
		    <li th:if="${pagination.hasPrevious}">
		      <a href="${?page=' + (pagination.startPage - 2) + '&amp;status=' + status}" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		    <li th:class="${i==pagination.currentPage? 'active':''}" th:each="i : ${#numbers.sequence( pagination.startPage, pagination.endPage )}">
		    	<a th:href="${i==pagination.currentPage? '#':'?page=' + (i-1) + '&amp;status=' + status}" th:text="${i}"></a>
		    </li>
		    <li th:if="${pagination.hasNext}">
		      <a href="${?page=' + (pagination.endPage) + '&amp;status=' + status}" aria-label="Next">
		        <span aria-hidden="true">&raquo;</span>
		      </a>
		    </li>
		  </ul>
	   </nav>
    </main>
  </div>
</body>
</html>
